package com.aaa.pro.controller;

import com.aaa.pro.service.JHTakeOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * fileName:JHTakeOutController
 * description:
 * author:JH
 * createTime:2020/3/7 15:42
 * version:1.0.0
 */
@RestController
public class JHTakeOutController {

    @Autowired
    private JHTakeOutService service;
    /**
     * 查询所有外卖商品和商品分类
     * @return
     */
    @RequestMapping("goodsList")
    public Map list(){
        Map map = new HashMap();
        map.put("list",service.getList());
        map.put("pro",service.getPro());
        return map;
    }
    /**
     * 模糊查询
     * @param name
     * @return
     */
    @RequestMapping("changeList")
    public Object change(String name){
        return service.getChange(name);
    }

    /**
     * 购物车数据
     * @param cart
     * @return
     */
    @RequestMapping("cartList")
    public Object cart(@RequestParam(value = "cart") List cart){
        System.out.println(cart.size());
        System.out.println(cart.remove(0));
        System.out.println(cart.get(0));
        return cart;
    }
}
